<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="法人标识" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankNoCd">
              <j-dict-select-tag type="list" v-model="model.bankNoCd" dictCode="llbb_juridical_person,BANKNAME,ID" placeholder="请选择法人标识" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="数据日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sjrq">
              <j-date placeholder="请选择数据日期" v-model="model.sjrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khh">
              <a-input v-model="model.khh" placeholder="请输入客户号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="内部机构号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nbjgh">
              <a-input v-model="model.nbjgh" placeholder="请输入内部机构号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="国民经济部门分类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gmjjbmfl">
              <a-input v-model="model.gmjjbmfl" placeholder="请输入国民经济部门分类"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="金融机构类型代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jrjglxdm">
              <a-input v-model="model.jrjglxdm" placeholder="请输入金融机构类型代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="企业规模" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qygm">
              <a-input v-model="model.qygm" placeholder="请输入企业规模"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="控股类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="kglx">
              <a-input v-model="model.kglx" placeholder="请输入控股类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="境内境外标志" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jnjwbz">
              <a-input v-model="model.jnjwbz" placeholder="请输入境内境外标志"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="经营所在地行政区划代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jyszdxzqhdm">
              <a-input v-model="model.jyszdxzqhdm" placeholder="请输入经营所在地行政区划代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="注册地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zcdz">
              <a-input v-model="model.zcdz" placeholder="请输入注册地址"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="授信额度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sxed">
              <a-input-number v-model="model.sxed" placeholder="请输入授信额度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="已用额度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yyed">
              <a-input-number v-model="model.yyed" placeholder="请输入已用额度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="所属行业" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sshy">
              <a-input v-model="model.sshy" placeholder="请输入所属行业"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="农村城市标志" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nccsbz">
              <a-input v-model="model.nccsbz" placeholder="请输入农村城市标志"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'DayReporForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/dayRepor/add",
          edit: "/dayRepor/edit",
          queryById: "/dayRepor/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>